package games.graphPath;

import games.graphPath.Graph.Edge;
import games.graphPath.Graph.Vertex;
import games.graphPath.GraphPathGenticSearch.GeneticVertex;

import java.util.ArrayList;
import java.util.List;

public class GraphPathGeneticState extends ArrayList<GeneticVertex> implements Comparable<GraphPathGeneticState>{
	
	private int _cost;
	
	private int _depth;
	
	private GraphPathGeneticState _parent;
	
	private List<Edge> _path;
	
	private int _curIndex;
	
	public GraphPathGeneticState(int depth, GraphPathGeneticState parent, List<Edge> path )
	{
		_curIndex = -1;
		_depth = depth;
		_parent = parent;
		_path = path;
		_cost=0;
		for (Edge e:path)
			_cost+=e.getCost();
	}
	
	public int getCost()
	{
		return _cost;		
	}
	
	public Vertex getVertex(int index)
	{
		_curIndex = index;
		return _path.get(index).getSrc();
	}
	
	public Vertex getNext()
	{
		return getVertex(_curIndex+1);
	}

	@Override
	public int compareTo(GraphPathGeneticState o) {
		return new Integer(_cost).compareTo(o.getCost());
	}
	
	

}
